package com.lsa.helpers;

import java.util.Arrays;
import java.util.List;

import junit.framework.Assert;
import junit.framework.TestCase;

public class TestCollectionUtils extends TestCase
{
	public void testPivotDivide() 
	{		
		int[] array = new int[]{5, 1, 3, 4, 6, 7, 9, 8, 2, 0};
		IntArrayListAdapter list = new IntArrayListAdapter(array);
		int piv = CollectionUtils.pivotDivide(list, 0, list.size() - 1,  3);
		Assert.assertEquals(4, piv);
		
		int[] testArray = Utils.createIntArray1D("0 1 3 2 4 7 9 8 6 5");
		assertEquals(true, Utils.compareArrays(array, testArray));
		
		///**************************************************************
		
		array = new int[]{5, 1, 3, 4, 6, 7, 9, 8, 2, 0};
		list = new IntArrayListAdapter(array);
		piv = CollectionUtils.pivotDivide(list, 0, list.size() - 1,  6);
		Assert.assertEquals(9, piv);

		testArray = Utils.createIntArray1D("0 1 3 4 6 7 5 8 2 9");
		assertEquals(true, Utils.compareArrays(array, testArray));		
		
	    ///**************************************************************
		
		array = new int[]{9, 8, 7, 6, 2, 7, 5, 1, 3, 4, 6, 7, 9, 8, 2, 0, 9, 8, 7, 6, 2, 7};
        list = new IntArrayListAdapter(array);
        piv = CollectionUtils.pivotDivide(list, 6, 16,  9);
        //Assert.assertEquals(9, piv);
         //6,16

        testArray = Utils.createIntArray1D("9, 8, 7, 6, 2, 7, 0, 1, 3, 2, 4, 7, 9, 8, 6, 5, 9, 8, 7, 6, 2, 7");
        assertEquals(true, Utils.compareArrays(array, testArray));
		
		///**************************************************************
	}
}
